home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / technical documentation / develop / develop issue 26 / develop issue 26 code / truffles - display mgr. / sprocket / sources / splashwindow.cp < prev    next >
Encoding:
Text File  |  1995-12-30  |  2.2 KB  |  80 lines

  1. /*
  2.     File:        SplashWindow.cp
  3.  
  4.     Contains:    a simple splash screen window
  5.                 
  6.     Written by: Dave Falkenburg
  7.     
  8.     Copyright:    © 1993-1995 by Dave Falkenburg, all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.     
  12.          <8>     1/20/95    DRF        Fix a double-dispose bug: there is no need to get rid of a
  13.                                     window’s picture. DisposeWindow will already KillPicture it.
  14.          <7>      1/3/95    DRF        Only show the splash window if there is a splash screen picture.
  15.          <6>    11/16/94    DRF        Add (StringPtr) cast to make PPCC happier.
  16.          <5>    11/12/94    DRF        Use NewColorOrBlackAndWhiteWindow.
  17.          <4>     11/8/94    DRF        Deal with a missing splash picture.
  18.          <3>     9/27/94    DRF         AppLib.h is now Sprocket.h
  19.          <2>      9/9/94    DRF        Reordered headers and removed redundant #includes.
  20.  */
  21.  
  22. #include "Sprocket.h"
  23. #include "SplashWindow.h"
  24.  
  25. #include <ToolUtils.h>
  26. #include <Resources.h>
  27.  
  28.  
  29. TSplashWindow::TSplashWindow()
  30.     {
  31.     this->CreateWindow(kNormalWindow);
  32.     }
  33.  
  34.  
  35. WindowRef
  36. TSplashWindow::MakeNewWindow(WindowRef behindWindow)
  37.     {
  38.     GrafPtr        oldPort;
  39.     Rect        splashPictRect,windowRect;
  40.     WindowRef    splashWindow;
  41.     
  42.     GetPort(&oldPort);
  43.  
  44.     fSplashPicture = GetPicture(kSplashPictureID);
  45.     
  46.     if (fSplashPicture)
  47.         {
  48.         MoveHHi((Handle) fSplashPicture);                        //    get it out of the way
  49.         splashPictRect = (**fSplashPicture).picFrame;
  50.         }
  51.     else
  52.         SetRect(&splashPictRect,0,0,0,0);
  53.         
  54.     //    normalize the rectangle
  55.     OffsetRect(&splashPictRect,-splashPictRect.left,-splashPictRect.top);
  56.  
  57.     //    center it on the main screen
  58.     windowRect = splashPictRect;
  59.     OffsetRect(&windowRect,((qd.screenBits.bounds.right-windowRect.right) >> 1),((qd.screenBits.bounds.bottom-windowRect.bottom) >> 1));
  60.     
  61.     splashWindow = NewWindow(nil,&windowRect,(StringPtr) "\p",false,dBoxProc,behindWindow,false,(long) this);
  62.  
  63.     if (fSplashPicture)
  64.         {
  65.         DetachResource((Handle) fSplashPicture);    // need to do so we don’t botch the resource map after closing
  66.         SetWindowPic(splashWindow,fSplashPicture);    // in case an Alert comes up
  67.  
  68.         ShowWindow(splashWindow);
  69.  
  70.         SetPortWindowPort(splashWindow);
  71.         BeginUpdate(splashWindow);                    //    avoid a flashing update event later
  72.             if (fSplashPicture)
  73.                 DrawPicture(fSplashPicture,&splashPictRect);
  74.         EndUpdate(splashWindow);                    //    avoid a flashing update event later
  75.         }
  76.         
  77.     SetPort(oldPort);
  78.     return splashWindow;
  79.     }
  80.